package com.netkit;

import java.util.Iterator;

import com.netkit.exception.ActionException;
import com.netkit.message.Message;

public class ActionChain {

	private Iterator<ActionFilter> it;
	
	public void setIterator(Iterator<ActionFilter> it){
		this.it = it;
	}

	public void doChain(Action action,Message message) throws ActionException{
		if(it.hasNext()){
			it.next().doFilter(action,message, this);
			return ;
		}
		
		action.execute(message);
	}
}
